package com.doubleview;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.metadata.WriteSheet;
import lombok.Data;

/**
 * @author huchengchao@kuaishou.com
 * Created on 2021-11-16
 */
public class EasyExcelUtils {


    public static void main(String[] args) {
        List<BountyBatchCreateElement> list =
                EasyExcel.read(new File("/Users/huchengchao/Downloads/女装6月分销政策发奖模版文件.xlsx")).head(BountyBatchCreateElement.class).sheet().doReadSync();
        int count = 2;
        for(BountyBatchCreateElement element : list) {
            System.out.println(count + ": " + element.getActivityId() + " " + element.getSellerId() + " " + element.getBountyAmount() + " " + element.getRemark());
            ++count;
        }
//        ExcelWriter writer =
//                EasyExcel.write(new File("/Users/huchengchao/test.xlsx")).excelType(ExcelTypeEnum.XLSX)
//                        .autoCloseStream(true).build();
//        WriteSheet sheet =
//                EasyExcel.writerSheet(0, "明细").head(SellerDeductPursueExportElement.class).build();
//        List<SellerDeductPursueExportElement> list = new ArrayList<>();
//        SellerDeductPursueExportElement element = new SellerDeductPursueExportElement();
//        element.sellerId = "1";
//        element.accountType = "1";
//        element.reasonDesc = "1";
//        element.orderId = "1";
//        element.status = "1";
//        element.amount = "1";
//        element.paidAmount = "1";
//        element.payTime = "-";
//        element.cTime = "2021-09-09 00:00:00";
//        list.add(element);
//        writer.write(list, sheet);
//        writer.finish();
    }

    @Data
    public static class BountyBatchCreateElement {
        @ExcelProperty(value = "活动id", index = 0)
        private String activityId;
        @ExcelProperty(value = "商家id", index = 1)
        private String sellerId;
        @ExcelProperty(value = "奖金金额", index = 2)
        private String bountyAmount;
        @ExcelProperty(value = "发放备注", index = 3)
        private String remark;
    }

    public static class SellerDeductPursueExportElement {

        @ExcelProperty(value = "商家id", index = 0)
        private String sellerId;

        @ExcelProperty(value = "账户类型", index = 1)
        private String accountType;

        @ExcelProperty(value = "原因", index = 2)
        private String reasonDesc;

        @ExcelProperty(value = "关联订单id", index = 3)
        private String orderId;

        @ExcelProperty(value = "状态", index = 4)
        private String status;

        @ExcelProperty(value = "总缴纳额", index = 5)
        private String amount;

        @ExcelProperty(value = "已缴金额", index = 6)
        private String paidAmount;

        @ExcelProperty(value = "缴纳完成时间", index = 7)
        private String payTime;

        @ExcelProperty(value = "创建时间", index = 8)
        private String cTime;
    }
}
